/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2013.06.02                                          *
 *                                                                       *
 *************************************************************************/

namespace FreeMAPs
{

inline void
StateIndicator::clear()
{
    d_state = State::INVALID_VALUE;
    d_verbose_level = FREEMAPS_INVALID_VALUE;
}


inline const std::string&
StateIndicator::get_object_name() const
{
    return d_object_name;
}


inline const std::string&
StateIndicator::get_full_name() const
{
    return d_full_name;
}


inline bool
StateIndicator::is_registered_in_info_manager() const
{
    return d_is_registered_in_info_manager;
}


inline State
StateIndicator::get_state() const
{
    return d_state;
}


inline void
StateIndicator::add_key_for_checking_consistence(
    const std::string& key,
    const std::string& message) const
{
 //   FREEMAPS_ASSERT_EQ (d_keys_to_be_checked_consistence.count (key), 0);

    d_keys_to_be_checked_consistence.insert (std::make_pair (key, std::make_pair (false, message)));
}


inline void
StateIndicator::finish_checking_consistence(
    const std::string& key) const
{
    if (d_keys_to_be_checked_consistence.count (key) > 0)
    {
        d_keys_to_be_checked_consistence[key].first = true;
    }
}


inline bool
StateIndicator::require_check_consistence()const
{
    for (std::map<std::string, std::pair<bool, std::string> >::const_iterator pos = d_keys_to_be_checked_consistence.begin();
            pos != d_keys_to_be_checked_consistence.end(); ++pos)
    {
        if (!pos->second.first)
        {
            return true;
        }
    }

    return false;
}


inline bool
StateIndicator::require_rebuilding() const
{
    return (d_state != State::GOOD);
}


inline void
StateIndicator::finish_rebuilding() const
{
    d_state = State::GOOD;
}


inline void
StateIndicator::update_state (
    const State state) const
{
    d_state = state;
}


inline bool
StateIndicator::is_analytic_function() const
{
    return false;
}


inline void
StateIndicator::active_verbose_mode(
    const int level)
{
    FREEMAPS_ASSERT (level == 0 || level == 2);
    d_verbose_level = level;
}


inline int
StateIndicator::get_verbose_level() const
{
    FREEMAPS_ASSERT (d_verbose_level > 0);
    return d_verbose_level;
}

}
